using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;

namespace UWBGL_XNA_Lib13
{
	public class UWB_WindowHandler : UWB_IWindowHandler
	{
		protected IntPtr m_hAttachedWindow;
		protected UWB_BoundingBox m_WCWindow;

		public UWB_WindowHandler()
		{
			m_WCWindow = new UWB_BoundingBox();
		}

		public override bool InitializeHandler(IntPtr hAttachedWindow)
		{
			if (!Control.FromHandle(hAttachedWindow).IsHandleCreated)
				return false;

			m_hAttachedWindow = hAttachedWindow;
			return true;
		}

		public bool hardwareToDevice(int hardwareX, int hardwareY, ref int deviceX, ref int deviceY)
		{
			if (!Control.FromHandle(m_hAttachedWindow).IsHandleCreated)
				return false;

			deviceX = hardwareX;
			deviceY = Control.FromHandle(m_hAttachedWindow).Height - hardwareY;
			return true;
		}

		public float getAspectRatio()
		{
			if (!Control.FromHandle(m_hAttachedWindow).IsHandleCreated)
				return 0.0f;

			Size size = Control.FromHandle(m_hAttachedWindow).Size;

			return (float)size.Width / (float)size.Height;
		}

		public void setWCWindow(ref UWB_BoundingBox w)
		{
			m_WCWindow = w;
		}

		public virtual void loadW2NDCXform()
		{
			return;
		}
	}
}
